package com.juneng.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.juneng.common.R;
import com.juneng.utils.Func;
import java.util.List;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import com.juneng.entity.OrderMsg;
import com.juneng.dto.OrderMsgDto;
import com.juneng.dto.OrderMsgQueryDto;
import com.juneng.vo.OrderMsgVo;
import com.juneng.service.IOrderMsgService;

/**
 * 订单商品信息 控制器
 *
 * @author zds
 * @since 2021-07-31
 */
@RestController
@AllArgsConstructor
@RequestMapping("orderMsg")
@Api(tags = "订单商品信息相关接口")
public class OrderMsgController {

	private IOrderMsgService orderMsgService;

	/**
	 * 详情
	 */
	@GetMapping("/detail")
	@ApiOperation(value = "详情", notes = "传入id")
	public R<OrderMsg> detail(Integer id) {
		OrderMsg detail = orderMsgService.getById(id);
		return R.success(detail);
	}

	/**
	 * 分页 订单商品信息
	 */
	@GetMapping("/page")
	@ApiOperation(value = "分页", notes = "传入orderMsg")
	public R<IPage<OrderMsgVo>> page(OrderMsgQueryDto dto) {
		IPage<OrderMsgVo> pages = orderMsgService.page(dto);
		return R.success(pages);
	}
	/**
	 * 列表 订单商品信息
	 */
	@GetMapping("/list")
	@ApiOperation(value = "不分页", notes = "传入orderMsg")
	public R<List<OrderMsg>> list(OrderMsgQueryDto dto) {
		List<OrderMsg> list = orderMsgService.list(dto);
		return R.success(list);
	}

	/**
	 * 新增 订单商品信息
	 */
	@PostMapping("/save")
	@ApiOperation(value = "新增", notes = "传入orderMsg")
	public R save(@RequestBody OrderMsgDto dto) {
		return R.success(orderMsgService.save(dto));
	}

	/**
	 * 修改 订单商品信息
	 */
	@PutMapping("/update")
	@ApiOperation(value = "修改", notes = "传入orderMsg")
	public R update(@RequestBody OrderMsgDto dto) {
		return R.success(orderMsgService.updateById(dto));
	}

	/**
	 * 删除 订单商品信息
	 */
	@DeleteMapping("/remove")
	@ApiOperation(value = "逻辑删除", notes = "传入ids")
	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
		return R.success(orderMsgService.deleteLogic(Func.toIntList(ids)));
	}
}
